' dw3 - returns the handle of the interrupt installed
' for ITEM_MEMORY
' dw1 - physical address on card
' dw2 - address range
' dw3 - returns the address to pass on to transfer commands
' dw4 - returns the address for direct user read/write
' dw5 - returns the CPU physical address of card
' for ITEM_IO
' dw1 - beginning of io address
' dw2 - io range
dw1 As Long
dw2 As Long
dw3 As Long
dw4 As Long
dw5 As Long
End Type
Global Const WD_CARD_ITEMS = 20
Type WD_CARD
dwItems As Long
Item(0 To WD_CARD_ITEMS - 1) As WD_ITEMS
End Type
Type WD_CARD_REGISTER
Card As WD_CARD ' card to register
fCheckLockOnly As Long ' only check if card is lockable, return hCard=1 if OK
hCard As Long ' handle of card
dwOptions As Long ' should be zero
cName(0 To 31) As Byte ' name of card
cDescription(0 To 100 - 1) As Byte ' description
End Type
Global Const WD_PCI_CARDS = 30
Type WD_PCI_SLOT
dwBus As Long
dwSlot As Long
dwFunction As Long
End Type
Type WD_PCI_ID
dwVendorId As Long
dwDeviceId As Long
End Type
Type WD_PCI_SCAN_CARDS
searchId As WD_PCI_ID ' if dwVendorId = 0, scan all
' vendor Ids
' if dwDeviceId = 0, scan all
' device Ids
dwCards As Long ' Number of cards found
cardId(0 To WD_PCI_CARDS - 1) As WD_PCI_ID
' VendorID & DeviceID of cards found
cardSlot(0 To WD_PCI_CARDS - 1) As WD_PCI_SLOT
' PCI slot info of cards found
End Type
Type WD_PCI_CARD_INFO
pciSlot As WD_PCI_SLOT ' PCI slot
Card As WD_CARD ' Get card parameters for PCI slot
End Type
Global Const PCI_ACCESS_OK = 0
Global Const PCI_ACCESS_ERROR = 1
Global Const PCI_BAD_BUS = 2
Global Const PCI_BAD_SLOT = 3
Type WD_PCI_CONFIG_DUMP
pciSlot As WD_PCI_SLOT ' PCI bus, slot and function number
pBuffer As PVOID ' buffer for read/write
dwOffset As Long ' offset in pci configuration space
' to read/write from
dwBytes As Long ' bytes to read/write from/to buffer
' returns the # of bytes read/written
fIsRead As Long ' if 1 then read pci config, 0 write pci config
dwResult As Long ' PCI_ACCESS_RESULT
End Type
Global Const WD_ISAPNP_CARDS = 16
Global Const WD_ISAPNP_COMPATIBLE_IDS = 10
Global Const WD_ISAPNP_COMP_ID_LENGTH = 7 ' ISA compressed ID is 7 chars long
Global Const WD_ISAPNP_ANSI_LENGTH = 32 ' ISA ANSI ID is limited to 32 chars long
Type WD_ISAPNP_COMP_ID
compID(0 To WD_ISAPNP_COMP_ID_LENGTH) As Byte
End Type
Type WD_ISAPNP_ANSI
ansi(0 To WD_ISAPNP_ANSI_LENGTH + 3) As Byte ' add 3 bytes for DWORD alignment
End Type
Type WD_ISAPNP_CARD_ID
cVendor As WD_ISAPNP_COMP_ID ' Vendor ID
dwSerial As Long ' Serial number of card
End Type
Type WD_ISAPNP_CARD
cardId As WD_ISAPNP_CARD_ID ' VendorID & serial number of cards found
dcLogicalDevices As Long ' Logical devices on the card
bPnPVersionMajor As Byte ' ISA PnP version Major
bPnPVersionMinor As Byte ' ISA PnP version Minor
bVendorVersionMajor As Byte ' Vendor version Major
bVendorVersionMinor As Byte ' Vendor version Minor
cIdent As WD_ISAPNP_ANSI ' Device identifier
End Type
Type WD_ISAPNP_SCAN_CARDS
searchId As WD_ISAPNP_CARD_ID ' if searchId.cVendor[0]==0 - scan all vendor IDs
' if searchId.dwSerial==0 - scan all serial numbers
dwCards As Long ' number of cards found
Card(0 To WD_ISAPNP_CARDS - 1) As WD_ISAPNP_CARD ' cards found
End Type
Type WD_ISAPNP_CARD_INFO
cardId As WD_ISAPNP_CARD_ID ' VendorID and serial number of card
dwLogicalDevice As Long ' logical device in card
cLogicalDeviceId As WD_ISAPNP_COMP_ID ' logical device ID
dwCompatibleDevices As Long ' number of compatible device IDs
CompatibleDevice(0 To WD_ISAPNP_COMPATIBLE_IDS - 1) As WD_ISAPNP_COMP_ID ' Compatible device IDs
cIdent As WD_ISAPNP_ANSI ' Device identifier
Card As WD_CARD ' get card parameters for the ISA PnP card
End Type
Global Const ISAPNP_ACCESS_OK = 0
Global Const ISAPNP_ACCESS_ERROR = 1
Global Const ISAPNP_BAD_ID = 2
Type WD_ISAPNP_CONFIG_DUMP
cardId As WD_ISAPNP_CARD_ID ' VendorID and serial number of card
dwOffset As Long ' offset in ISA PnP configuration space to read/write from
fIsRead As Long ' if 1 then read ISA PnP config, 0 write ISA PnP config
bData As Byte ' result data of byte read/write
dwResult As Long ' ISAPNP_ACCESS_RESULT
End Type
Global Const WD_PCMCIA_CARDS = 8
Global Const WD_PCMCIA_VERSION_LEN = 4
Global Const WD_PCMCIA_MANUFACTURER_LEN = 48
Global Const WD_PCMCIA_PRODUCTNAME_LEN = 48
Global Const WD_PCMCIA_MAX_SOCKET = 2
Global Const WD_PCMCIA_MAX_FUNCTION = 2
Type WD_PCMCIA_SLOT
uSocket As Byte ' Specifies the socket number (first socket is 0)
uFunction As Byte ' Specifies the function number (first function is 0)
uPadding0 As Byte ' 2 bytes padding so structure will be 4 bytes aligned
uPadding1 As Byte
End Type
Type WD_PCMCIA_ID
dwManufacturerId As Long ' card manufacturer
dwCardId As Long ' card type and model
End Type
Type WD_PCMCIA_SCAN_CARDS
searchId As WD_PCMCIA_ID ' device ID to search for
dwCards As Long ' number of cards found
cardId(0 To WD_PCMCIA_CARDS - 1) As WD_PCMCIA_ID ' device IDs of cards found
cardSlot(0 To WD_PCMCIA_CARDS - 1) As WD_PCMCIA_SLOT ' pcmcia slot info of cards found
End Type
Type WD_PCMCIA_CARD_INFO
pcmciaSlot As WD_PCMCIA_SLOT ' pcmcia slot
Card As WD_CARD ' get card parameters for pcmcia slot
cVersion(0 To WD_PCMCIA_VERSION_LEN - 1) As Byte
cManufacturer(0 To WD_PCMCIA_MANUFACTURER_LEN - 1) As Byte
cProductName(0 To WD_PCMCIA_PRODUCTNAME_LEN - 1) As Byte
dwManufacturerId As Long ' card manufacturer
dwCardId As Long ' card type and model
dwFuncId As Long ' card function code
End Type
Type WD_PCMCIA_CONFIG_DUMP
pcmciaSlot As WD_PCMCIA_SLOT
pBuffer As PVOID ' buffer for read/write
dwOffset As Long ' offset in pcmcia configuration space to
' read/write from
dwBytes As Long ' bytes to read/write from/to buffer
' returns the number of bytes read/wrote
fIsRead As Long ' if 1 then read pci config, 0 write pci config
dwResult As Long ' PCMCIA_ACCESS_RESULT
End Type
Global Const SLEEP_NON_BUSY = 1
Type WD_SLEEP
dwMicroSeconds As Long ' Sleep time in Micro Seconds (1/1,000,000 Second)
dwOptions As Long ' can be:
' SLEEP_NON_BUSY this is accurate only for times above 10000 uSec
End Type
Global Const D_OFF = 0
Global Const D_ERROR = 1
Global Const D_WARN = 2
Global Const D_INFO = 3
Global Const D_TRACE = 4
Global Const S_ALL As Long = &HFFFFFFFF
Global Const S_IO As Long = &H8
Global Const S_MEM As Long = &H10
Global Const S_INT As Long = &H20
Global Const S_PCI As Long = &H40
Global Const S_DMA As Long = &H80
Global Const S_MISC As Long = &H100
Global Const S_LICENSE As Long = &H200
Global Const S_ISAPNP As Long = &H400
Global Const S_PCMCIA As Long = &H800
Global Const S_KER_PLUG As Long = &H10000
Global Const S_CARD_REG As Long = &H2000
Global Const DEBUG_STATUS = 1
Global Const DEBUG_SET_FILTER = 2
Global Const DEBUG_SET_BUFFER = 3
Global Const DEBUG_CLEAR_BUFFER = 4
Global Const DEBUG_DUMP_SEC_ON = 5
Global Const DEBUG_DUMP_SEC_OFF = 6
'from win32API
Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function DeviceIoControl Lib "kernel32" ( _
ByVal hDevice As Long, _
ByVal dwIoControlCode As Long, _
lpInBuffer As Any, _
ByVal nInBufferSize As Long, _
ByVal lpOutBuffer As Long, _
ByVal nOutBufferSize As Long, _
lpBytesReturned As Long, _
ByVal lpOverlapped As Long) As Long
Private Const GENERIC_READ = &H80000000
Private Const FILE_SHARE_READ = &H1
Private Const FILE_SHARE_WRITE = &H2
Private Const OPEN_EXISTING = 3
Private Const FILE_FLAG_OVERLAPPED = &H40000000
Global Const INVALID_HANDLE_VALUE = -1
'call this function with the variable of which you need the pointer and the last two params pass 1
'address = WD_VB_GetAddress (Variable, 1, 1) 'this extracts the address of Variable
Declare Function WD_VB_GetAddress Lib "kernel32" Alias "MulDiv" (ByRef dwNum As Any, ByVal one As Long, ByVal one_ As Long) As Long
'Use external DLL for interrupt handling
Declare Function InterruptThreadEnable Lib "WD_VB.DLL" _
Alias "WD_VB_InterruptThreadEnable" ( _
ByRef phThread As Long, _
ByVal hWD As Long, _
ByRef pInt As Any, _
ByVal IntHandler As Long, _
ByVal pData As Long, _
ByVal hWnd As Long) As Long
Declare Sub InterruptThreadDisable Lib "WD_VB.DLL" _
Alias "WD_VB_InterruptThreadDisable" (ByVal hThread As Long)
Type WD_DEBUG
dwCmd As Long ' DEBUG_COMMAND as DEBUG_STATUS, DEBUG_SET_FILTER, DEBUG_SET_BUFFER, DEBUG_CLEAR_BUFFER
' used for DEBUG_SET_FILTER
dwLevel As Long ' DEBUG_LEVEL as D_ERROR, D_WARN..., or D_OFF to turn debugging off
dwSection As Long ' DEBUG_SECTION as for all sections in driver as S_ALL
' for partial sections as S_IO, S_MEM...
dwLevelMessageBox As Long ' DEBUG_LEVEL to print in a message box
' used for DEBUG_SET_BUFFER
dwBufferSize As Long ' size of buffer in kernel
End Type
Type PChar
charPtr As Long
End Type
Type WD_DEBUG_DUMP
pcBuffer As PChar ' buffer to receive debug messages
dwSize As Long ' size of buffer in bytes
End Type
Type WD_KERNEL_PLUGIN
hKernelPlugIn As Long
pcDriverName As PChar
pcDriverPath As PChar ' if NULL the driver will be searched in the windows system directory
pOpenData As PVOID
End Type
Global Const PIPE_TYPE_CONTROL = 0
Global Const PIPE_TYPE_ISOCHRONOUS = 1
Global Const PIPE_TYPE_BULK = 2
Global Const PIPE_TYPE_INTERRUPT = 3
Global Const WD_USB_MAX_PIPE_NUMBER = 32
Global Const WD_USB_MAX_ENDPOINTS = 32
Global Const WD_USB_MAX_INTERFACES = 30
Global Const WD_USB_MAX_DEVICE_NUMBER = 127
Global Const USB_DIR_IN = 1
Global Const USB_DIR_OUT = 2
Global Const USB_DIR_IN_OUT = 3
Type WD_USB_ID
dwVendorId As Long
dwProductId As Long
End Type
Type WD_USB_PIPE_INFO
dwNumber As Long ' Pipe 0 is the default pipe
dwMaximumPacketSize As Long
type As Long ' USB_PIPE_TYPE
direction As Long ' USB_DIR
' Isochronous, Bulk, Interrupt are either USB_DIR_IN or USB_DIR_OUT
' Control are USB_DIR_IN_OUT
dwInterval As Long ' interval in ms relevant to Interrupt pipes
End Type
Type WD_USB_CONFIG_DESC
dwNumInterfaces As Long
dwValue As Long
dwAttributes As Long
MaxPower As Long
End Type
Type WD_USB_INTERFACE_DESC
dwNumber As Long
dwAlternateSetting As Long
dwNumEndpoints As Long
dwClass As Long
dwSubClass As Long
dwProtocol As Long
dwIndex As Long
End Type
Type WD_USB_ENDPOINT_DESC
dwEndpointAddress As Long
dwAttributes As Long
dwMaxPacketSize As Long
dwInterval As Long
End Type
Type WD_USB_INTERFACE
Interface As WD_USB_INTERFACE_DESC
Endpoints(0 To WD_USB_MAX_ENDPOINTS - 1) As WD_USB_ENDPOINT_DESC
End Type
Type WD_USB_CONFIGURATION
uniqueId As Long
dwConfigurationIndex As Long
configuration As WD_USB_CONFIG_DESC
dwInterfaceAlternatives As Long
Interface(0 To WD_USB_MAX_INTERFACES - 1) As WD_USB_INTERFACE
End Type
Type WD_USB_HUB_GENERAL_INFO
fBusPowered As Long
dwPorts As Long ' number of ports on this hub
dwCharacteristics As Long ' Hub Charateristics
dwPowerOnToPowerGood As Long ' port power on till power good in 2ms
dwHubControlCurrent As Long ' max current in mA
End Type
Type WD_USB_DEVICE_GENERAL_INFO
deviceId As WD_USB_ID
dwHubNum As Long
dwPortNum As Long
fHub As Long
fFullSpeed As Long
dwConfigurationsNum As Long
deviceAddress As Long
hubInfo As WD_USB_HUB_GENERAL_INFO
End Type
Type WD_USB_DEVICE_INFO
dwPipes As Long
Pipe(0 To WD_USB_MAX_PIPE_NUMBER - 1) As WD_USB_PIPE_INFO
End Type
Type WD_USB_SCAN_DEVICES
searchId As WD_USB_ID ' if dwVendorId==0 - scan all vendor IDs
' if dwProductId==0 - scan all product IDs
dwDevices As Long
uniqueId(0 To WD_USB_MAX_DEVICE_NUMBER - 1) As Long ' a unique id to identify the device
deviceGeneralInfo(0 To WD_USB_MAX_DEVICE_NUMBER - 1) As WD_USB_DEVICE_GENERAL_INFO
End Type
Global Const USB_TRANSFER_HALT = 1 ' USB TRANSFER options
Type WD_USB_TRANSFER
hDevice As Long ' handle of USB device to read from or write to
dwPipe As Long ' pipe number on device
fRead As Long
dwOptions As Long ' USB_TRANSFER options:
' USB_TRANSFER_HALT halts the pervious no wait transfer
pBuffer As Long ' pointer to buffer to read/write
dwBytes As Long
dwTimeout As Long ' timeout for the transfer in milli-seconds. 0==>no timeout.
dwBytesTransfered As Long ' returns the number of bytes actually read/written
SetupPacket(0 To 8 - 1) As Byte ' setup packet for control pipe transfer
fOK As Long ' transfer succeeded
End Type
Type WD_USB_DEVICE_REGISTER
uniqueId As Long ' the device unique ID
dwConfigurationIndex As Long ' the index of the configuration to register
dwInterfaceNum As Long ' interface to register
dwInterfaceAlternate As Long
hDevice As Long ' handle of device
Device As WD_USB_DEVICE_INFO ' description of the device
dwOptions As Long ' should be zero
cName(0 To 32 - 1) As Byte ' name of card
cDescription(0 To 100 - 1) As Byte ' description
End Type
Type WD_USB_RESET_PIPE
hDevice As Long
dwPipe As Long
End Type
Private IOCTL_WD_USB_RESET_PIPE As Long
Private IOCTL_WD_USB_RESET_DEVICE As Long
Private IOCTL_WD_USB_SCAN_DEVICES As Long
Private IOCTL_WD_USB_SCAN_DEVICES_V432 As Long
Private IOCTL_WD_USB_TRANSFER As Long
Private IOCTL_WD_USB_DEVICE_REGISTER As Long
Private IOCTL_WD_USB_DEVICE_UNREGISTER As Long
Private IOCTL_WD_USB_GET_CONFIGURATION As Long
Dim WinDriverGlobalDW As Long
Global Const WD_TYPE As Long = 38200
Global Const FILE_ANY_ACCESS As Long = 0
Global Const METHOD_NEITHER As Long = 3
' This is an implementation of a WinIOCTL macro (CTL_CODE)